<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style>
            *{
                padding: 0px;
                margin: 0px;
                list-style: none;
            }
            body{
                background-image: url(pic.jpg);
            }
            textarea{
                width: 600px;
                resize: none;
                margin: 50px auto;
                display: block;
                outline: none;
            }
            ul{
                width: 600px;
                margin: 0px auto;
            }
            li{
                margin: 20px 0px;
                border: 1px solid black;
                position: relative;
                padding: 20px;
                background: whitesmoke;
                opacity: 0.5;
            }
            .del{
                position: absolute;
                right: 1px;
                top: -3px;
                cursor: pointer;
            }
            button{
                width: 600px;
                background: #f60;
                border:none;
                cursor:pointer;
                outline:none;
                margin: 40px auto;
                display: block;
                line-height: 40px;
                color: white;
            }
        
        </style>
    </head>
    <body>
        <textarea name="" id="txt" cols="30" rows="10"></textarea>
        <button id="btn">发送</button>
        <ul id="box">
            <li>今天一直在下雨！！！！！
                <p>2021-06-01  10:30:32</p>
                <span class="del" onclick="del(this)">X</span>
            </li>
            <li>昨天下午语文课太搞笑了！
                <p>2021-05-31 16:00:25</p>
                <span class="del" onclick="del(this)">X</span>
            </li>
        </ul>

        <script>
            var txt = document.getElementById('txt');
            var btn = document.getElementById('btn');
            var box = document.getElementById('box');
            var year = new Date().getFullYear();
            var month = new Date().getMonth();
            var date = new Date().getDate();
            var hour = new Date().getHours();
            var min = new Date().getMinutes();
            var ss = new Date().getSeconds();
            btn.onclick=function(){
                if(txt.value==''){
                    alert('请输入内容！')}else{
                var text = txt.value;
                var tag = document.createElement('li');
                tag.innerHTML=`${text}
                <p>${year}-${month}-${date}&nbsp&nbsp${hour}:${min}:${ss}</p>
                <span class="del" onclick="del(this)">X</span>`
                box.appendChild(tag);
                    
                }
            }
            function del(a){
                a.parentNode.parentNode.removeChild(a.parentNode)
            }
        </script>
    </body>
</html>